<?php
namespace app\api\controller\v1;
use think\admin\Controller;
use think\Response;
use app\data\model\DataDevice;
use app\data\model\DataCatToiletLog;
use app\data\model\DataCat;
use app\data\service\CatService;
use think\facade\Db;
/**
 * 图表数据
 * @class Chart
 * @package app\api\controller\v1
 *
 */
class Chart extends Controller
{
    //如厕曲线图
    public function toilet(){
        $id = input('get.id');//设备iotId
        $member_id = $this->request->uid;
        $cat_id = input('get.cat_id');
        $type = input('get.type')?input('get.type'):'0'; //today,week,month
        $date = input('get.date')?input('get.date'):'';
        $catService = new CatService();
       // $data['toilet'] = $catService->toilet_chart_data($id,$cat_id,$type,$date);
        $data['toilet'] = $catService->toilet_chart_data_by_mid($member_id,$cat_id,$type,$date);


        $this->success('获取成功',$data);
    }
    //体重曲线图
    public function weight(){
        $id = input('get.id');//设备iotId
        $member_id = $this->request->uid;
        $cat_id = input('get.cat_id');
        $type = input('get.type')?input('get.type'):'0'; //today,week,month
        $date = input('get.date')?input('get.date'):'';
        $catService = new CatService();
        //$data['weight'] = $catService->weight_chart_data($id,$cat_id,$type,$date);
        $data['weight'] = $catService->weight_chart_data_by_mid($member_id,$cat_id,$type,$date);
        $data['count'] = count($data['weight']);
        $this->success('获取成功',$data);
    }
}
